pimpas.DOM = Class.create( );
pimpas.Extends(pimpas.DOM, pimpas.Object);
pimpas.Extends(pimpas.DOM,
	{
		getElementsByClassName: function getElementsByClassName(strClassName, strTagName, oElm){
			var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
			var arrReturnElements = new Array();
			strClassName = strClassName.replace(/\-/g, "\\-");
			var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
			var oElement;
			for(var i=0; i<arrElements.length; i++){
				oElement = arrElements[i];      
				if(oRegExp.test(oElement.className))
					arrReturnElements.push(oElement);
			}
			return (arrReturnElements);
		},
		getElement: function(el) {
			var backup = el;
			if(typeof el == "string")
				el = document.getElementById(el);
			if(el == null && typeof backup == 'string')
				// try by form reference
				return this.getElementByFormReference(backup);
			return el;
		},
		getElementByFormReference: function(name) {
			// try looking for all form elements
			var forms = document.getElementsByTagName('form');
			var el = null;
			for(var i=0;i<forms.length;i++)
				for(var j=0;j<forms[i].elements.length;j++)
					if(forms[i].elements[j].name == name) {
						el = forms[i].elements[j];
						break;
					}
			return el;
		},
		convertToNodeList: function(el) {
			el = this.getElement(el);
			if(!(el instanceof NodeList)) {
				var frm = this.getParentForm(el);
				el = frm.elements[el.name];
			}				
			return el;
		},
		getObjectValue: function(el, convertToNode) {
			el = this.getElement(el);
			if(!this.isDefined(convertToNode)) convertToNode = true;
			if(this.isInput(el) || this.isTextArea(el)) {
				if(this.isRadio(el)) {
					if(convertToNode) {
						if(pimpas.Browser.isIE)
							el = this.getParentForm(el).elements[el.name];
						else
							el = this.convertToNodeList(el);
					}
					var value = new Array();
					var j = 0;
					if(el.length == undefined) 
						return (el.checked) ? el.value : null;
					for(var i=0;i<el.length;i++)
						if(el[i].checked)
							value[j++] = el[i].value;
					return value;
				} else if(this.isCheckbox(el)) {
					if(convertToNode) {
						if(pimpas.Browser.isIE)
							el = this.getParentForm(el).elements[el.name];
						else
							el = this.convertToNodeList(el);
					}
					var j = 0;
					if(el.length == undefined)
						return (el.checked) ? el.value : null;
					value = [];
					for(var i=0;i<el.length;i++)
						if(el[i].checked)
							value[j++] = el[i].value;
					return value;
				} else
					return el.value;
			}
			else if(this.isSelect(el)) {
				if(this.isMultipleSelect(el)) {
					var values = [];
					var j = 0;
					for(var i=0;i<el.options.length;i++)
						if(el.options[i].selected) values[j++] = el.options[i].value;
					return values;
				} else {
					var indx = el.selectedIndex;
					return el.options[indx].value;
				}
			}
			return el.innerHTML;
		},
		setObjectValue: function(el, value) {
			el = this.getElement(el);
			if(this.isInput(el) || this.isTextArea(el)) {
				if(this.isRadio(el)) {
					if(pimpas.Browser.isIE)
						el = this.getParentForm(el).elements[el.name];
					else
						if(!(el instanceof NodeList)) {
							var frm = this.getParentForm(el);
							el = frm.elements[el.name];
						}
					if(value != null)
						value = value.split(" ").join().split(",");
					else return;
					for(var i=0;i<el.length;i++)
						el[i].checked = false;
					for(var i=0;i<el.length;i++)
						if(el[i].value == value) {
							el[i].checked = true;
							break;
						}
				} else if(this.isCheckbox(el)) {
					if(pimpas.Browser.isIE)
						el = this.getParentForm(el).elements[el.name];
					else
						if(!(el instanceof NodeList)) {
							var frm = this.getParentForm(el);
							el = frm.elements[el.name];
						}
					if(value != null)
						value = value.split(" ").join().split(",");
					else return;
					// selectOne?! Boolean?!
					if(!(el instanceof NodeList)) {
						var v = value[0];
						el.checked = (v=='true') ? true : false;
						return;
					}
					
					for(var i=0;i<el.length;i++) el[i].checked = false;
					for(var i=0;i<value.length;i++)
						for(var j=0;j<el.length;j++)
							if(el[j].value == value[i]) el[j].checked = true;
				} else {
					if(pimpas.Browser.isIE)
						el.setAttribute("value", value);
					else
						el.value = value;
				}
			}
			else if(this.isSelect(el)) {
				if(this.isMultipleSelect(el)) {
					if(value != null)
						value = value.split(" ").join().split(",");
					else return;
					this.clearSelectedOptions(el);
					for(var i=0;i<value.length;i++)
						for(var j=0;j<el.options.length;j++)
							if(el.options[j].value == value[i]) el.options[j].selected = true;
				} else
					for(var i=0;i<el.options.length;i++)
						if(el.options[i].value == value) {
							el.selectedIndex = i;
							return;
						}
				return;
			} else {
				try {
					el.innerHTML = value;
				} catch(e) {
					// ie, dont change TABLE, THEAD, TFOOT, TR values, only for readOnly
					// so, burn in hell IE, we hate u!
				}
			}
		},
		isInput: function(el) {
			return this.getElement(el).tagName == "INPUT";	
		},
		isSelect: function(el) {
			return this.getElement(el).tagName == "SELECT";	
		},
		isMultipleSelect: function(el) {
			return this.isSelect(this.getElement(el)) && this.getElement(el).getAttribute("multiple") == "multiple" ||
				this.getElement(el).getAttribute("multiple") == "true";
		},
		isTextArea: function(el) {
			return this.getElement(el).tagName == "TEXTAREA";	
		},
		isButton: function(el) {
			return this.isInput(this.getElement(el)) && this.getElement(el).type == "button";	
		},
		isSubmit: function(el) {
			return this.isInput(this.getElement(el)) && this.getElement(el).type == "submit";	
		},
		isRadio: function(el) {
			return this.isInput(this.getElement(el)) && this.getElement(el).type == "radio";
		},
		isCheckbox: function(el) {
			return this.isInput(this.getElement(el)) && this.getElement(el).type == "checkbox";
		},
		isInputHidden: function(el) {
			return this.isInput(this.getElement(el)) && this.getElement(el).type == "hidden";
		},
		isScript: function(el) {
			return this.getElement(el).tagName == 'SCRIPT';
		},
		isStyle: function(el) {
			return this.getElement(el).tagName == 'STYLE';
		},
		isForm: function(el) {
			return this.getElement(el).tagName == 'FORM';	
		},
		isVisible: function(el) {
			el = this.getElement(el);
			return (this.getStyle(el, "visibility") != 'hidden' && this.getStyle(el, "display") != 'none') || (this.getStyle(el, "visibility") != "hidden" && this.getStyle(el, "visibility") != '');
		},
		isDisabled: function(el) {
			el = this.getElement(el);
			return el.getAttribute("disabled") != null && el.getAttribute("disabled").toString()=="true";
		},
		isReadOnly: function(el) {
			el = this.getElement(el);
			return el.getAttribute("readOnly")=="true";
		},
		toDisable: function() {
			var el = null;
			for(var i=0;i<arguments.length;i++) {
				el = this.getElement(arguments[i]);
				if(this.isDisabled(el)) return;
				el.setAttribute("disabled", "true");
			}
		},
		toEnable: function() {
			var el = null;
			for(var i=0;i<arguments.length;i++) {
				el = this.getElement(arguments[i]);
				if(!this.isDisabled(el)) return;
				el.removeAttribute("disabled");
			}
		},
		toReadWrite: function() {
			var el = null;
			for(var i=0;i<arguments.length;i++) {
				el = this.getElement(arguments[i]);
				if(!this.isReadOnly(el)) continue;
				el.removeAttribute("readOnly");
			}
		},
		toReadOnly: function() {
			var el = null;
			for(var i=0;i<arguments.length;i++) {
				el = this.getElement(arguments[i]);
				if(this.isReadOnly(el)) continue;
				el.setAttribute("readOnly", "true");
			}
		},
		toVisible: function() {
			var el = null;
			for(var i=0;i<arguments.length;i++) {
				el = this.getElement(arguments[i]);
				if(this.isVisible(el)) continue;
				var styles = new Array();
				styles["display"] = "block";
				styles["visibility"] = "visible";
				
				this.setStyle( el, styles );
			}
		},
		toHidden: function() {
			var el = null;
			for(var i=0;i<arguments.length;i++) {
				el = this.getElement(arguments[i]);
				if(!this.isVisible(el)) continue;
				var styles = new Array();
				styles["display"] = "none";
				styles["visibility"] = "hidden";
				this.setStyle( el, styles);
			}
		},
		toggleVisibility: function() {
			var el = null;
			for(var i=0;i<arguments.length;i++) {
				el = this.getElement(arguments[i]);
				(this.isVisible(el)) ? this.toHidden(el) : this.toVisible(el);
			}
		},
		remove: function(el) {
			el = this.getElement(el);
			el.parentNode.removeChild(el);
		},
		add: function(parent, el) {
			parent = this.getElement(parent);
			el = this.getElement(el);
			parent.appendChild(el);
		},
		insertBefore: pimpas.insertBefore,
		insertAfter: function(parent, newNode, refNode) {
			parent = this.getElement(parent);
			refNode = this.getElement(refNode);
			parent.insertAfter(newNode, refNode);
		},
		update: function(el, html) {
			el = this.getElement(el);
			try {
				el.innerHTML = html.stripScripts();
				var timer = new pimpas.Timer(10, function() {html.evalScripts();}, null);
				timer.go();
			} catch(e) {
				// simple setvalue
				this.setObjectValue( el, html );
			}
		},
		getClassNames: function(el) {
			el = this.getElement(el);
			return el.className.split(" ");
		},
		hasClassName: function(el, clazz) {
			el = this.getElement(el);
			var clazzs = this.getClassNames(el);
			for(var i=0;i<clazzs.length;i++)
				if(clazzs[i] == clazz) return true;
			return false;
		},
		addClassName: function(el, clazz) {
			el = this.getElement(el);
			if(this.hasClassName(el, clazz)) return;
			el.className += " "+clazz;
		},
		setClassName: function(el, clazz) {
			el = this.getElement(el);
			el.className = clazz;
		},
		resetClassName: function(el) {
			el = this.getElement(el);
			el.className = "";
		},
		removeClassName: function(el, clazz) {
			el = this.getElement(el);
			if(!this.hasClassName(el, clazz)) return;
			
			var clazzs = this.getClassNames(el);
			var newClazzs = new Array();
			for(var i=0;i<clazzs.length;i++) {
				if(clazzs[i] == clazz) continue;
				newClazzs.push( clazzs[i] );
			}
			this.resetClassName(el);
			while(newClazzs.length>0) this.addClassName(newClazzs.shift());
		},
		isEmpty: function(el) {
			return this.getElement(el).innerHTML.match(/^\s*$/);
		},
	    getStyle: function(el, style) {
			el = this.getElement(el);
			var value = el.style[style.camelize()];
			
			if (!value) {
			  if (document.defaultView && document.defaultView.getComputedStyle) {
				var css = document.defaultView.getComputedStyle(el, null);
				value = css ? css.getPropertyValue(style) : null;
			  } else if (el.currentStyle) {
				value = el.currentStyle[style.camelize()];
			  }
			}
			if (pimpas.Browser.isOpera && ['left', 'top', 'right', 'bottom'].have(style))
			  if (this.getStyle(el, 'position') == 'static') value = 'auto';
		
			return value == 'auto' ? null : value;
		},
  	    setStyle: function(el, style) {
			el = this.getElement(el);
			for (name in style)
				try {
					el.style[name.camelize()] = style[name];
				} catch(e) {};
			
	    },
		getHeight: function(el) {
			return this.getElement(el).offsetHeight; 
		},
		scrollTo: function(el) {
			el = this.getElement(el);
			var x = el.x ? el.x : el.offsetLeft,
				y = el.y ? el.y : el.offsetTop;
			window.scrollTo(x, y);
		},
		createElement: function(type, id) {
			var el = document.createElement(type);
			if(id!=null) el.setAttribute("id", id);
			return el;
		},
		createTextNode: function(text) {
			var el = document.createTextNode(text);
			return el;
		},
		havChild: function(parent, child) {
			parent = this.getElement(parent);
			child = this.getElement(child);
			return parent.childNodes.have(child);
		},
		replace: function(old, newOne) {
			old = this.getElement(old);
			newOne = this.getElement(newOne);
			old.parentNode.replace( old, newOne );
		},
		createOption: function(text, value) {
			return new Option(text, value);
		},
		getOption: function(el, value) {
			el = this.getElement(el);
			if(!this.isSelect(el)) return;
			for(var i=0;i<el.options.length;i++)
				if(el.options[i].value == value) return el.options[i];
			return null;
		},
		addOption: function(el, text, value) {
			el = this.getElement(el);
			if(!this.isSelect(el)) return;
			el.options[el.options.length] = this.createOption(text, value);
		},
		removeOption: function(el, value) {
			el = this.getElement(el);
			if(!this.isSelect(el)) return;
			op = this.getOption(el, value);
			if(op != null) {
				var a = [];
				var j = 0;
				for(var i=0;i<el.options.length;i++)
					if(el.options[i].value != value) a[j++] = el.options[i];
				el.options.length = 0;
				for(var i=0;i<a.length;i++) this.addOption(el, a[i].text, a[i].value);
				a = null;
			}
		},
		clearAllOptions: function(el) {
			el = this.getElement(el);	
			if(!this.isSelect(el)) return;
			
			el.options.length = 0;
		},
		clearSelectedOptions: function(el) {
			el = this.getElement(el);
			if(!this.isSelect(el)) return;
			if(this.isMultipleSelect(el))
				for(var i=0;i<el.options.length;i++)
					el.options[i].selected = false;
			else
				el.selectedIndex = 0;
		}
	}
);

pimpas.Extends(pimpas.DOM, 
	{
		focus: function(el) {
			el = this.getElement(el);
			try {
				el.focus( );
			} catch(e) {
				
			}
		},
		select: function(el) {
			el = this.getElement(el);
			try {
				el.select( );	
			} catch(e) {
				
			}
		},
		isField: function(el) {
			el = this.getElement(el);
			return (this.isSelect(el) || (this.isInput(el) && !this.isButton(el) && !this.isSubmit(el)) || this.isTextArea(el));
		},
		isSerializable: function(el) {
			el = this.getElement(el);
			return (this.isSelect(el) || this.isInput(el) || this.isTextArea(el));
		},
		serialize: function(el, convert) {
			el = this.getElement(el);
			var ar = new Array();
			var value = this.getObjectValue(el, convert);
			if(this.isRadio(el) || this.isCheckbox(el) || this.isMultipleSelect(el))
				if(value == null || value.length == 0) return null;
			
			ar.push((el.id) ? el.id : el.name);
			ar.push(encodeURIComponent(value));
			return ar;
		},
		getParentForm: function(el) {
			el = this.getElement(el);
			while(el != null && !this.isForm(el))
				el = el.parentNode;
			return el;
		},
		serializeForm: function(el, filter) {
			el = this.getElement(el);
			if(!this.isForm(el)) el = this.getParentForm(el);
			var ser = new Array();
			var notFound = false;
			var filters = new Array();
			if(pimpas.DOM.isDefined(filter) && filter instanceof pimpas.Filter)
				filters.push(filter);
			var accepted = true;
			var ft = null;
			var tmp = null;
			for(var i=0;i<el.elements.length;i++) {
				if(this.isSerializable(el.elements[i])) {
					// execute all listeners
					accepted = true;
					while(filters.length > 0) {
						ft = filters.pop();
						try {
							accepted = ft.accept( el.elements[i] );
						} catch(e) {
							accepted = false;	
						}
						if(!accepted) break;
					}
					if(accepted) {
						tmp = this.serialize(el.elements[i], false);
						if(tmp != null)
							ser.push(tmp);
					}
				}
			}
			
			var str = new Array();
			while(ser.length>0)
				str.push(ser.shift( ).join("="));

			return str.join("&");
		}
	}
);

pimpas.Extends(pimpas.DOM,
	{
		getDimensions: function(el) {
			el = this.getElement(el);
			if(this.isVisible(el))
			  return {width: el.offsetWidth, height: el.offsetHeight};
			
			var els = el.style;
			var originalVisibility = els.visibility;
			var originalPosition = els.position;
			els.visibility = 'hidden';
			els.position = 'absolute';
			els.display = '';
			var originalWidth = el.clientWidth;
			var originalHeight = el.clientHeight;
			els.display = 'none';
			els.position = originalPosition;
			els.visibility = originalVisibility;
			return {width: originalWidth, height: originalHeight};    
		},
		getRealOffset: function(el) {
			el = this.getElement(el);
			var valueT = 0, valueL = 0;
			do {
				valueT += el.scrollTop  || 0;
				valueL += el.scrollLeft || 0; 
				el = el.parentNode;
			} while (el);
			
			return [valueL, valueT];
		},
		getCumulativeOffset: function(el) {
			el = this.getElement(el);
			var valueT = 0, valueL = 0;
			do {
				valueT += el.offsetTop  || 0;
				valueL += el.offsetLeft || 0;
				el = el.offsetParent;
			} while (el);
			
			return [valueL, valueT];
		},
		getPositionedOffset: function(el) {
			el = this.getElement(el);
			var valueT = 0, valueL = 0;
			do {
				valueT += el.offsetTop  || 0;
				valueL += el.offsetLeft || 0;
				el = el.offsetParent;
				if (el) {
					p = this.getStyle(el, 'position');
					if (p == 'relative' || p == 'absolute') break;
				}
			} while (el);
			
			return [valueL, valueT];
		},
		getOffsetParent: function(el) {
			el = this.getElement(el);
			if (el.offsetParent) return el.offsetParent;
			if (el == document.body) return el;
			
			while ((el = el.parentNode) && el != document.body)
				if (this.getStyle(el, 'position') != 'static')
					return el;
			
			return document.body;
		},
		clone: function(source, target) {
			source = this.getElement(source);
			target = this.getElement(target);
			
			var styles = new Array();
			
			styles["position"]	 = 'absolute';
			var offsets 		= this.getCumulativeOffset(source);
			styles["top"] 		= offsets[1] + 'px';
			styles["left"]   	= offsets[0] + 'px';
			styles["width"]  	= source.offsetWidth + 'px';
			styles["height"] 	= source.offsetHeight + 'px';
			
			pimpas.DOM.setStyle( target, styles );
		},
		setCursor: function(el, c) {
			el = this.getElement(el);
			var styles = new Array();
			styles["cursor"] = c;
			this.setStyle( el, styles );
		},
		within: function(el1, el2) {
			var targetPosition = pimpas.DOM.getCumulativeOffset(el2);
			var sourcePosition = pimpas.DOM.getCumulativeOffset(el1);
			var targetDimension = pimpas.DOM.getDimensions(el2);
			var sourceDimension = pimpas.DOM.getDimensions(el1);
			var styles = new Array();
			styles["border"] = "";
			if(sourcePosition[0] > targetPosition[0] && sourcePosition[1] > targetPosition[1]) {
				x = targetPosition[0];
				y = targetPosition[1];
				var horizontal = ((sourcePosition[0] + el1.offsetWidth) - x) / 
					el2.offsetWidth;
				var vertical = ((sourcePosition[1] + el1.offsetHeight) - y) / 
					el1.offsetHeight;
				
				return (horizontal > 0 && horizontal < 1 && ((el1.offsetHeight + sourcePosition[1]) < (el2.offsetHeight + targetPosition[1])));
			}
		}
  	}
);

pimpas.Extends(pimpas.DOM,
			   {
				   isDefined: function(ar) {
					    try {
							return ar != null && ar != undefined;   
						} catch(e) { return false; };
				   }
			   }
);
// drag-drop
pimpas.Extends(pimpas.DOM,
   {
	   enableDrag: function(el) {
			el = this.getElement(el);
			if(this.isDragAble(el)) return;
			pimpas.DOM.Event.addListener( el, pimpas.DOM.Event.MOUSEDOWN, pimpas.DOM.dragInit, false ); 
			pimpas.DOM.dragDropChangeCursor( el, true );			
	   },
	   dragDropChangeCursor: function(el, onoroff) {
	   		el = this.getElement(el);
			if(pimpas.DOM.isDefined(onoroff) && onoroff == true)
				pimpas.DOM.setCursor( el, pimpas.DOM.Cursors.MOVE );
			else
				pimpas.DOM.setCursor( el, pimpas.DOM.Cursors.DEFAULT );
	   },
	   dragInit: function(e) {
			e = pimpas.DOM.Event.fixEvent(e);
			var el = pimpas.DOM.Event.getElement(e);
			var styles = new Array();
			
			el.setAttribute("oldBottom", pimpas.DOM.getStyle( el, 'bottom' ));
			el.setAttribute("oldRight", pimpas.DOM.getStyle( el, 'right' ));
			el.setAttribute("oldPosition", pimpas.DOM.getStyle( el, 'position' ));
			el.setAttribute("oldZIndex", pimpas.DOM.getStyle( el, 'zIndex' ));
			
			if(pimpas.DOM.getStyle( el, 'bottom' ) == null || pimpas.DOM.getStyle( el, 'bottom' ) == '')
				styles["bottom"] = "0px";
			if(pimpas.DOM.getStyle( el, 'right' ) == null || pimpas.DOM.getStyle( el, 'right' ) == '')
				styles["right"] = "0px";
			styles["position"] = "relative";
			styles["zIndex"] = "99999999999";
			
			pimpas.DOM.setStyle(el, styles);
				
		    pimpas.DOM.Event.removeListener( el, pimpas.DOM.Event.MOUSEDOWN, pimpas.DOM.dragInit, false ); 
			
			pimpas.DOM.Event.addListener( document, pimpas.DOM.Event.MOUSEMOVE, pimpas.DOM.dragStart, false );
			pimpas.DOM.Event.addListener( document, pimpas.DOM.Event.MOUSEUP, pimpas.DOM.dragEnd, false );
			
			el.setAttribute("Drag-LastMouseX", e.clientX);
			el.setAttribute("Drag-LastMouseY", e.clientY);
			el.setAttribute("DragAble", "true");
	   },
	   dragStart: function(e) {
		    e = pimpas.DOM.Event.fixEvent(e);
			var el = pimpas.DOM.Event.getElement(e);
			var ey	= e.clientY;
			var ex	= e.clientX;
			var y = parseInt(pimpas.DOM.getStyle(el, "bottom"));
			var x = parseInt(pimpas.DOM.getStyle(el, "right"));
			var nx = x + ((ex - el.getAttribute("Drag-LastMouseX")) * -1);
			var ny = y + ((ey - el.getAttribute("Drag-LastMouseY")) * -1);
			
			var styles = new Array();
			
			styles["right"] = nx + "px";
			styles["bottom"] = ny + "px";
			
			pimpas.DOM.setStyle( el, styles );
			
			el.setAttribute("Drag-LastMouseX", ex);
			el.setAttribute("Drag-LastMouseY", ey);
	   },
	   dragEnd: function(e) {
		    e = pimpas.DOM.Event.fixEvent(e);
			var el = pimpas.DOM.Event.getElement(e);
			pimpas.DOM.disableDrag(el);
	   },
	   isDragAble: function(el) {
		   el = this.getElement(el);
		   return el.getAttribute("DragAble")=="true";
	   },
	   disableDrag: function(el) {
		    el = this.getElement(el);
			if(!this.isDragAble(el)) return;
			
			pimpas.DOM.Event.removeListener( document, pimpas.DOM.Event.MOUSEMOVE, pimpas.DOM.dragStart, false );
			pimpas.DOM.Event.removeListener( document, pimpas.DOM.Event.MOUSEUP, pimpas.DOM.dragEnd, false );
			pimpas.DOM.dragDropChangeCursor( el, false );			
			el.removeAttribute("Drag-LastMouseX");
			el.removeAttribute("Drag-LastMouseY");
			

			// recover
			var styles = new Array();
			styles["bottom" ] 		= el.getAttribute("oldBottom");
			styles["right" ] 		= el.getAttribute("oldRight");
			styles["position" ] 	= el.getAttribute("oldPosition");
			styles["zIndex" ] 		= el.getAttribute("oldZIndex");
			
			//pimpas.DOM.setStyle( el, styles );
			//alert(pimpas.DOM.getStyle( el, 'position' ));
			
			el.removeAttribute("oldBottom");
			el.removeAttribute("oldRight");
			el.removeAttribute("oldPosition");
			el.removeAttribute("oldZIndex");
			
	   },
	   switchDragAble: function(el) {
		   el = this.getElement(el);
		   (!this.isDraAble(el)) ? this.enableDrag(el) : this.disableDrag(el);
	   }
   }
);

// filters
pimpas.DOM.Filters = Class.create( );
pimpas.Extends(pimpas.DOM.Filters,
	{
		applyOpacity: function(el, n) {
			el = pimpas.DOM.getElement( el );
			var styles = new Array();
			if(pimpas.Browser.isMozilla)
				styles["MozOpacity"] = n;
			else if(pimpas.Browser.isIE)
				styles["filter"] = "alpha(opacity="+(n*100)+")";
			else if(pimpas.Browser.isOpera)
				styles["opacity"] = n;
				
			pimpas.DOM.setStyle( el, styles );
		}
	}
);


// cursors
pimpas.DOM.Cursors = Class.create( );
pimpas.Extends(pimpas.DOM.Cursors,
	{
		DEFAULT: 		'default',
		CROSSHAIR: 		'crosshair',
		ERESIZE: 		'e-resize',
		HAND: 			'hand',
		HELP: 			'help',
		MOVE: 			'move',
		NRESIZE: 		'n-resize',
		NERESIZE:		'ne-resize',
		NWRESIZE: 		'nw-resize',
		SRESIZE: 		's-resize',
		SERESIZE: 		'se-resize',
		SWRESIZE: 		'sw-resize',
		TEXT: 			'text',
		WRESIZE: 		'w-resize',
		WAIT:			'wait'
	}
);

pimpas.Extends(pimpas.DOM,
	{
		clone: function(source) {
			source = this.getElement(source);
			var target = pimpas.DOM.createElement(source.tagName);
			for(var prop in source) {
				try {
					target[prop] = source[prop];	
				} catch(e){}
			}
			return target;
		}
	}
);

pimpas.DOM.initialize();